﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using SAServices.Model;
using SAServices.Service;

namespace SAServices
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    public class SAService : ISAService
    {
        //category methods.
        //
        public List<CategoryInfo> GetRootCategories()
        {
            return PubServiceMethod.Instance().GetRootCategories();
        }

        //
        public List<CategoryInfo> GetSubCategories(CategoryInfo parentCategory)
        {
            return PubServiceMethod.Instance().GetSubCategories(parentCategory);
        }

        //
        public bool IsCategoryContainsFamilyFromVendor(CategoryInfo category, int vendorId, bool bIncludeSubCategory)
        {
            return PubServiceMethod.Instance().IsCategoryContainsFamilyFromVendor(category, vendorId, bIncludeSubCategory);
        }

        //
        public bool AddCategory(CategoryInfo newCategoryInfo)
        {
            return PubServiceMethod.Instance().AddCategory(newCategoryInfo);
        }

        //
        public bool DeleteCategory(Guid cateId)
        {
            return PubServiceMethod.Instance().DeleteCategory(cateId);
        }

        //
        public bool UpdateCategory(CategoryInfo updateCategoryInfo)
        {
            return PubServiceMethod.Instance().UpdateCategory(updateCategoryInfo);
        }

        //
        public CategoryInfo GetCategoryInfoByCateId(Guid cateId)
        {
            return PubServiceMethod.Instance().GetCategoryInfoByCateId(cateId);
        }

        //standard methods.
        //
        //
        public bool AddStandard(StandardInfo newStandardInfo)
        {
            return PubServiceMethod.Instance().AddStandard(newStandardInfo);
        }

        //
        public bool UpdateStandard(StandardInfo updateStandardInfo)
        {
            return PubServiceMethod.Instance().UpdateStandard(updateStandardInfo);
        }

        //
        public bool DeleteStandard(string standardName)
        {
            return PubServiceMethod.Instance().DeleteStandard(standardName);
        }

        //
        public StandardInfo GetStandardByName(string standardName)
        {
            return PubServiceMethod.Instance().GetStandard(standardName);
        }

        //
        public StandardInfo GetStandard(int standardId)
        {
            return PubServiceMethod.Instance().GetStandard(standardId);
        }

        //
        public List<StandardInfo> GetAllStandards()
        {
            return PubServiceMethod.Instance().GetAllStandards();
        }

        //vendor methods.
        //
        //
        public bool AddVendor(VendorInfo newVendorInfo)
        {
            return PubServiceMethod.Instance().AddVendor(newVendorInfo);
        }

        //
        public bool UpdateVendor(VendorInfo updateVendorInfo)
        {
            return PubServiceMethod.Instance().UpdateVendor(updateVendorInfo);
        }

        //
        public bool DeleteVendor(string vendorName)
        {
            return PubServiceMethod.Instance().DeleteVendor(vendorName);
        }

        //
        public VendorInfo GetVendorByName(string vendorName)
        {
            return PubServiceMethod.Instance().GetVendor(vendorName);
        }

        //
        public VendorInfo GetVendor(int vendorId)
        {
            return PubServiceMethod.Instance().GetVendor(vendorId);
        }

        //
        public List<VendorInfo> GetAllVendors()
        {
            return PubServiceMethod.Instance().GetAllVendors();
        }

        //family & parameter methods.
        //
        public bool PublishFamily(FamilyInfo familyInfo, FamilyAttrInfo familyAttrInfo, FamilyTableInfo familyTableInfo)
        {
            return PubServiceMethod.Instance().PublishFamily(familyInfo, familyAttrInfo, familyTableInfo);
        }

        //
        public bool UpdateFamily(FamilyInfo familyInfo, FamilyAttrInfo familyAttrInfo, FamilyTableInfo familyTableInfo)
        {
            return PubServiceMethod.Instance().UpdateFamily(familyInfo, familyAttrInfo, familyTableInfo);
        }

        //
        public bool DeleteFamily(Guid familyId)
        {
            return PubServiceMethod.Instance().DeleteFamily(familyId);
        }

        //
        public FamilyAttrInfo GetFamilyAttrInfoByType(Guid familyId, FamilyAttrType type)
        {
            return PubServiceMethod.Instance().GetFamilyAttrInfo(familyId, type);
        }

        //
        public FamilyAttrInfo GetFamilyAttrInfo(Guid familyId)
        {
            return PubServiceMethod.Instance().GetFamilyAttrInfo(familyId);
        }

        public Byte[] GetFamilyThumbnailPic(Guid familyId)
        {
            return PubServiceMethod.Instance().GetFamilyThumbnailPic(familyId);
        }

        //
        public List<FamilyInfo> GetFamiliesByCategoryId(Guid cateId)
        {
            return PubServiceMethod.Instance().GetFamiliesByCategoryId(cateId);
        }

        public List<FamilyInfo> GetFamiliesByCategoryIdnew(Guid cateId, string str, string searchString)
        {
            return PubServiceMethod.Instance().GetFamiliesByCategoryIdnew(cateId, str, searchString);
        }

        public FamilyInfo GetFamilyInfo(Guid famiId)
        {
            return PubServiceMethod.Instance().GetFamilyInfo(famiId);
        }

        public List<FamilyInfo> GetFamiliesByVendorId(int vendorId, string searchString)
        {
            return PubServiceMethod.Instance().GetFamiliesByVendorId(vendorId, searchString);
        }

        public List<FamilyInfo> GetFamiliesByCategoryVendorId(Guid cateId, int vendorId, string searchString,string str)
        {
            return PubServiceMethod.Instance().GetFamiliesByCategoryVendorId(cateId, vendorId, searchString,str);
        }

        public List<FamilyInfo> GetFamiliesByStandardId(int standardId)
        {
            return PubServiceMethod.Instance().GetFamiliesByStandardId(standardId);
        }

        //
        public List<FamilyInfo> SearchFamilies(string searchString)
        {
            return PubServiceMethod.Instance().SearchFamilies(searchString);
        }

        //

        public List<FamilyInfo> SearchFamiliesByVendor(string searchString, int vendorid)
        {
            return PubServiceMethod.Instance().SearchFamiliesByVendor(searchString, vendorid);
        }

        //

        public List<ParameterInfo> GetFamilyKeyParameters(Guid familyId)
        {
            return PubServiceMethod.Instance().GetFamilyKeyParameters(familyId);
        }

        //
        public List<ParameterInfo> GetFamilyParameters(Guid familyId)
        {
            return PubServiceMethod.Instance().GetFamilyParameters(familyId);
        }

        //
        public ParameterInfo GetFamilyParameterInfo(Guid parameterId)
        {
            return PubServiceMethod.Instance().GetFamilyParameterInfo(parameterId);
        }

        //
        public List<ParameterValueInfo> GetParamVals(Guid parameterId, List<ParameterValueInfo> paramConstrains)
        {
            return PubServiceMethod.Instance().GetParamVals(parameterId, paramConstrains);
        }

        //
        public ParameterValueInfo GetParamVal(Guid familyId, Guid instanceId, Guid parameterId)
        {
            return PubServiceMethod.Instance().GetParamVal(familyId, instanceId, parameterId);
        }

        //
        public System.Data.DataTable GetSubFamilyTable(Guid familyId, List<ParameterValueInfo> paramConstraints)
        {
            return PubServiceMethod.Instance().GetSubFamilyTable(familyId, paramConstraints);
        }

        //
        public List<ParameterValueInfo> GetDriveParameterVals(Guid familyId, Guid instanceId)
        {
            return PubServiceMethod.Instance().GetDriveParameterVals(familyId, instanceId);
        }

        //inventor methods.
        //
        //
        public Byte[] GeneratePart(Guid familyId, Guid instanceId, List<ParameterInfo> driveParams, string fileExtension)
        {
            return PubServiceMethod.Instance().GeneratePart(familyId, instanceId, driveParams, fileExtension);
        }

        //cache methods.
        //
        //
        public bool GenerateCache(Guid familyId)
        {
            return PubServiceMethod.Instance().GenerateCache(familyId);
        }

        //
        public bool DeleteCache(Guid familyId)
        {
            return PubServiceMethod.Instance().DeleteCache(familyId);
        }

        //
        public bool IsFamilyCached(Guid guid)
        {
            return PubServiceMethod.Instance().IsFamilyCached(guid);
        }

        //
        public List<ParameterInfo> GetParameters(Byte[] modelData)
        {
            return PubServiceMethod.Instance().GetParameters(modelData);
        }

        public int CheckUserAuthority(string username)
        {
            return PubServiceMethod.Instance().checkUserAuthority(username);
        }

        public bool ValidateUser(string username, string password)
        {
            return PubServiceMethod.Instance().ValidateUser(username, password);
        }
    }
}
